// GxFillEventSink.cpp : implementation file
//

#include "stdafx.h"
#include "SpeedOrder.h"
#include "GxFillEventSink.h"
#include "P2_i.c"
#include "OrderManager.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// GxFillEventSink

IMPLEMENT_DYNCREATE(GxFillEventSink, CCmdTarget)

GxFillEventSink::GxFillEventSink()
{
	EnableAutomation();
	m_pOrderMgr = NULL;
}

GxFillEventSink::~GxFillEventSink()
{
}


void GxFillEventSink::OnFinalRelease()
{
	// When the last reference for an automation object is released
	// OnFinalRelease is called.  The base class will automatically
	// deletes the object.  Add additional cleanup required for your
	// object before calling the base class.
	m_Cookie = 0;
	CCmdTarget::OnFinalRelease();
}


BEGIN_MESSAGE_MAP(GxFillEventSink, CCmdTarget)
	//{{AFX_MSG_MAP(GxFillEventSink)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

BEGIN_DISPATCH_MAP(GxFillEventSink, CCmdTarget)
	//{{AFX_DISPATCH_MAP(GxFillEventSink)
	DISP_FUNCTION(GxFillEventSink, "OnNewFill", OnNewFill, VT_EMPTY, VTS_DISPATCH)
	DISP_FUNCTION(GxFillEventSink, "OnFillUpdated", OnFillUpdated, VT_EMPTY, VTS_DISPATCH)
	//}}AFX_DISPATCH_MAP
END_DISPATCH_MAP()

// Note: we add support for IID_IGxFillEventSink to support typesafe binding
//  from VBA.  This IID must match the GUID that is attached to the 
//  dispinterface in the .ODL file.

// {97643DA4-3161-45BD-BFA6-AD94C061FC4A}
//static const IID IID_IGxFillEventSink =
//{ 0x97643da4, 0x3161, 0x45bd, { 0xbf, 0xa6, 0xad, 0x94, 0xc0, 0x61, 0xfc, 0x4a } };

BEGIN_INTERFACE_MAP(GxFillEventSink, CCmdTarget)
	INTERFACE_PART(GxFillEventSink, DIID_IGxFillEvents, Dispatch)
END_INTERFACE_MAP()

/////////////////////////////////////////////////////////////////////////////
// GxFillEventSink message handlers

void GxFillEventSink::OnNewFill(LPDISPATCH a_GxFill) 
{
	// TODO: Add your dispatch handler code here
	if (m_pOrderMgr)
		m_pOrderMgr->OnNewFill(a_GxFill);
}

void GxFillEventSink::OnFillUpdated(LPDISPATCH a_GxFill) 
{
	// TODO: Add your dispatch handler code here
	if (m_pOrderMgr)
		m_pOrderMgr->OnFillUpdated(a_GxFill);
}
